package com.medical.admin.hospital.controller;

import com.medical.admin.hospital.common.dto.ProjectDto;
import com.medical.admin.hospital.common.vo.DownMenu;
import com.medical.admin.hospital.common.vo.PageVo;
import com.medical.admin.hospital.common.vo.ProjectVo;
import com.medical.admin.hospital.service.ProjectService;
import com.qf.medical.response.ResponseEntity;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
/**
 * @description: 项目信息管理
 * @author: LuAn
 * @date: 2024/4/30
 */
@RestController
@RequestMapping("/project")
public class ProjectController {
    @Resource
    private ProjectService projectService ;

    @GetMapping("/page")
    @ApiOperation("分页查询项目信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "comboTypeTitle", value = "套餐名称"),
            @ApiImplicitParam(name = "pageNum",value = "当前页"),
            @ApiImplicitParam(name = "pageSize",value = "页大小")})
    public ResponseEntity<PageVo<ProjectVo>> list(String comboName, @RequestParam(defaultValue = "1")
    int pageNum, @RequestParam(defaultValue = "10") int pageSize){
        return ResponseEntity.success(projectService.list(comboName,pageNum,pageSize));
    }

    @PostMapping("/add")
    @ApiOperation("新增项目类型")
    @ApiImplicitParam(name = "projectDto",value = "项目信息")
    public ResponseEntity<Integer> add(@RequestBody ProjectDto projectDto){
        return ResponseEntity.success(projectService.insert(projectDto));
    }

    @ApiOperation("修改项目信息")
    @PutMapping("/modify")
    @ApiImplicitParam(name = "projectDto" ,value = "项目信息")
    public ResponseEntity<Integer> modify(@RequestBody ProjectDto projectDto){
        return ResponseEntity.success(projectService.update(projectDto));
    }

    @ApiOperation("删除项目信息")
    @DeleteMapping("/remove")
    @ApiImplicitParam(name = "projectId" ,value = "项目Id")
    public ResponseEntity<Integer> remove(@NotNull Long projectId){
        return ResponseEntity.success(projectService.delete(projectId));
    }

    @ApiOperation("查询项目详情")
    @GetMapping("/detail")
    @ApiImplicitParam(name = "comboId" ,value = "项目ID")
    public ResponseEntity<ProjectVo> detail(@NotNull Long projectId){
        return ResponseEntity.success(projectService.select(projectId));
    }

    @ApiOperation("下拉展示套餐信息")
    @GetMapping("/showCombo")
    public ResponseEntity<DownMenu> showDownMenu(){
        return ResponseEntity.success(projectService.selectComboType());
    }
}
